#include <stdio.h>
#include <stdlib.h>

typedef struct {
    int num;
    int count;
} Number;
void exchange(Number* p1,Number* p2)
{
	Number temp=*p1;
	*p1=*p2;
	*p2=temp;
}
int main() {
    int n;
    scanf("%d", &n);
    int arr[n];
    int count2[1001] = {0}; // Since numbers are <= 1000
    int added[1001] = {0}; // To track which numbers have been added to the 'numbers' array

    for (int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
        count2[arr[i]]++;
    }

    Number number[1001];
    int index = 0;
    for (int i = 0; i <= 1000; i++) {
        if (count2[i] > 0 && !added[i]) {
            number[index].num = i;
            number[index].count = count2[i];
            added[i] = 1; // Mark this number as added
            index++;
        }
    }
    int max=number[0].count;
	for(int i=0;i<index-1;i++)
	{
		for(int s=0;s<index-1-i;s++)
		{
			if(number[s].count<number[s+1].count||(number[s].count==number[s+1].count)&&number[s].num>number[s+1].num)
			{
				exchange(&number[s],&number[s+1]);
			}
		}
	}
    for (int i = 0; i < index; i++) {
        printf("%d %d\n", number[i].num, number[i].count);
    }

    return 0;
}
